import { UPDATE_COLLAPSED_TYPE } from './types';
import { commonLS } from '../../utils/common'

const reducer = (
  state = {
    collapsed: (() => {
      const [err, collapsed] = commonLS.get('collapsed')
      return err ? false : collapsed
    })(),
  },
  action = {},
) => {
  const newState = { ...state }
  const { type } = action
  switch (type) {
    case UPDATE_COLLAPSED_TYPE:
      newState.collapsed = !newState.collapsed
      break;

    default:
      break;
  }
  return newState
}
export default reducer;
